<script>
import {ref, onMounted} from 'vue'

export default {
  name: 'FirstPage',
  data() {
    return {
      skills: [
        {name: '前端开发', percent: 70},
        {name: '后端开发', percent: 85},
        {name: '数据库', percent: 70},
        {name: '英语学习', percent: 95}
      ],

      features: [
        {
          icon: 'el-icon-edit-outline',
          title: '智能默写',
          description: '根据学习进度智能安排单词默写计划，提高记忆效率'
        },
        {
          icon: 'el-icon-data-line',
          title: '数据分析',
          description: '详细记录学习数据，直观展示学习成果和薄弱环节'
        },
        {
          icon: 'el-icon-refresh',
          title: '循环复习',
          description: '采用科学的间隔重复算法，巩固记忆效果'
        },
        {
          icon: 'el-icon-user',
          title: '个性化学习',
          description: '根据个人学习情况定制专属学习计划'
        }
      ],

      socialLinks: [
        {icon: 'el-icon-s-custom', link: '#', label: '个人主页'},
        {icon: 'el-icon-s-cooperation', link: '#', label: '博客'},
        {icon: 'el-icon-s-management', link: '#', label: 'GitHub'}
      ],

      activeSection: 'project',
      showParticles: false,
      typingText: '',
      typingIndex: 0,
      fullText: '单词默写助手 - 您的英语学习好帮手',
      typingSpeed: 150,
      showContact: false
    }
  },
  methods: {
    switchSection(sectionId) {
      this.activeSection = sectionId
      this.sections.forEach(section => {
        section.active = section.id === sectionId
      })
    },

    typeText() {
      if (this.typingIndex < this.fullText.length) {
        this.typingText += this.fullText.charAt(this.typingIndex)
        this.typingIndex++
        setTimeout(this.typeText, this.typingSpeed)
      }
    },

    createParticles() {
      if (!this.showParticles) return
      const particlesContainer = document.querySelector('.particles-container')
      if (!particlesContainer) return
      for (let i = 0; i < 30; i++) {
        const particle = document.createElement('div')
        particle.classList.add('particle')
        const size = Math.random() * 8 + 2
        const posX = Math.random() * particlesContainer.offsetWidth
        const posY = Math.random() * particlesContainer.offsetHeight
        particle.style.width = `${size}px`
        particle.style.height = `${size}px`
        particle.style.left = `${posX}px`
        particle.style.top = `${posY}px`
        particle.style.opacity = Math.random() * 0.5 + 0.3
        particle.style.animation = `float ${Math.random() * 6 + 3}s linear infinite`
        particle.style.animationDelay = `${Math.random() * 5}s`
        particlesContainer.appendChild(particle)
      }
    },
    scrollToAuthor() {
      const el = document.querySelector('.author-section')
      if (el) el.scrollIntoView({ behavior: 'smooth' })
    }
  },
  mounted() {
    this.typeText()
    this.showParticles = true
    setTimeout(() => {
      this.createParticles()
    }, 500)
  },
  // created() {
  //   onMounted( () => {
  //     this.typeText()
  //       this.showParticles.value = true
  //       setTimeout(() => {
  //         this.createParticles()
  //       }, 500)
  //     }
  //   )
  // }
}

</script>

<template>
  <div class="about-container">
    <!-- 背景效果 -->
    <div class="particles-container"></div>

    <!-- 顶部标题区域 -->
    <div class="header-section">
      <div class="typing-container">
        <h1 class="typing-text">{{ typingText }}</h1>
      </div>
      <div class="login-btn-container">
        <router-link to="/login" class="login-btn">立即登录</router-link>
        <button class="login-btn about-btn" @click="scrollToAuthor">关于作者</button>
      </div>
      <div class="nav-tabs">
        <div
          v-for="section in sections"
          :key="section.id"
          :class="['nav-item', { active: section.active }]"
          @click="switchSection(section.id)"
        >
          {{ section.title }}
        </div>
      </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="main-content">
      <!-- 项目介绍部分 -->
      <section class="content-section project-section">
        <div class="section-inner">
          <h2 class="section-title">项目介绍</h2>
          <p class="section-description">
            这是一款专为英语学习者打造的单词默写应用，采用科学的记忆方法，帮助用户高效记忆英语单词。
            通过智能算法分析学习数据，为用户提供个性化的学习计划，让英语学习更加高效、有趣。
          </p>

          <div class="features-grid">
            <div
              v-for="(feature, index) in features"
              :key="index"
              class="feature-card card-hover animate-float-medium"
              :style="{ animationDelay: index * 0.2 + 's' }"
            >
              <i :class="feature.icon"></i>
              <h3>{{ feature.title }}</h3>
              <p>{{ feature.description }}</p>
            </div>
          </div>

          <div class="tech-stack">
            <h3>技术栈</h3>
            <div class="tech-items">
              <div class="tech-item">Vue.js</div>
              <div class="tech-item">Element UI</div>
              <div class="tech-item">Vant</div>
              <div class="tech-item">Axios</div>
              <div class="tech-item">Vuex</div>
              <div class="tech-item">SpringBoot</div>
              <div class="tech-item">Redis</div>
              <div class="tech-item">MySQL</div>
            </div>
          </div>
        </div>
      </section>

      <!-- 关于作者部分 -->
      <section class="content-section author-section">
        <div class="section-inner">
          <h2 class="section-title">关于作者</h2>
          <div class="author-profile">
            <div class="author-avatar">
              <div class="avatar-inner">
                <img src="/headerImage.jpg" alt="作者头像" class="author-img"/>
              </div>
            </div>
            <div class="author-info">
              <p class="author-bio">
                热爱编程和英语学习的全栈开发者，致力于将技术与教育相结合，
                开发出更加实用、高效的学习工具，帮助更多人轻松学习英语。
                熟悉前后端技术，对教育类应用有独到见解。
              </p>

              <div class="skills-container">
                <h3>技能掌握</h3>
                <div class="skills-list">
                  <div
                    v-for="(skill, index) in skills"
                    :key="index"
                    class="skill-item"
                  >
                    <div class="skill-info">
                      <span class="skill-name">{{ skill.name }}</span>
                      <span class="skill-percent">{{ skill.percent }}%</span>
                    </div>
                    <div class="skill-bar">
                      <div
                        class="skill-progress"
                        :style="{ width: skill.percent + '%' }"
                      ></div>
                    </div>
                  </div>
                </div>
              </div>
              <div>
                <!--                联系作者-->
                <div class="contact-btn-container">
                  <button class="login-btn contact-btn" @click="showContact = true">联系作者</button>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>
      <!-- 弹窗 -->
      <div v-if="showContact" class="contact-modal-backdrop">
        <div class="contact-modal">
          <h2>联系作者</h2>
          <div style="text-align: left">
            <p>
              <i class="el-icon-message" style="font-size: 1.5rem; margin-left: 40px; vertical-align: middle; color: #64b5f6; "></i>
              <span> 邮箱：2039967837@qq.com</span>
            </p>
            <p>
              <i class="fab fa-weixin" style="font-size: 1.5rem; margin-left: 40px; vertical-align: middle; color: #64b5f6;"></i>
              <span> 微信：c2888158</span>
            </p>
          </div>
          <button class="close-btn" @click="showContact = false">关闭</button>
        </div>
      </div>
    </div>

    <!-- 底部区域 -->
    <div class="footer-section">
      <p>© 让英语学习更高效</p>
    </div>
  </div>
</template>

<style scoped>
.about-container {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1a237e 0%, #0d47a1 50%, #01579b 100%);
  color: #f0f9ff;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* 粒子背景 */
.particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

.particle {
  position: absolute;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

@keyframes float {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-20px) rotate(180deg);
  }
  100% {
    transform: translateY(0) rotate(360deg);
  }
}

/* 顶部区域 */
.header-section {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 40px 0;
}

.typing-container {
  margin-bottom: 30px;
}

.typing-text {
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0;
  display: inline-block;
  position: relative;
  color: #f0f9ff;
  text-shadow: 0 0 10px rgba(0, 0, 255, 0.5);
}

.typing-text::after {
  content: "|";
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* 立即登录按钮样式 */
.login-btn-container {
  margin-top: 18px;
  margin-bottom: 10px;
  text-align: center;
}

.login-btn {
  display: inline-block;
  padding: 12px 36px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(90deg, #1976d2 0%, #64b5f6 100%);
  border: none;
  border-radius: 30px;
  box-shadow: 0 4px 16px rgba(25, 118, 210, 0.15);
  cursor: pointer;
  transition: background 0.3s, transform 0.2s;
  text-decoration: none;
  margin-right: 18px;
}

.login-btn:last-child {
  margin-right: 0;
}

.about-btn {
  margin-left: 0;
}

.login-btn:hover {
  background: linear-gradient(90deg, #64b5f6 0%, #1976d2 100%);
  transform: translateY(-2px) scale(1.04);
}

/* 导航标签 */
.nav-tabs {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.nav-item {
  padding: 10px 20px;
  margin: 0 10px;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
}

.nav-item::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: #f0f9ff;
  transition: width 0.3s ease;
}

.nav-item:hover::after {
  width: 100%;
}

.nav-item.active::after {
  width: 100%;
}

/* 主要内容区域 */
.main-content {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* 内容区域 */
.content-section {
  position: relative;
  z-index: 1;
  width: 100%;
}

.section-inner {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.section-inner:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.section-title {
  font-size: 2rem;
  margin-bottom: 20px;
  text-align: center;
  color: #f0f9ff;
}

.section-description {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 30px;
  text-align: center;
}

/* 功能卡片 */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.feature-card {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  padding: 25px;
  text-align: center;
  transition: all 0.3s ease;
  height: 100%;
}

.feature-card i {
  font-size: 2.5rem;
  margin-bottom: 15px;
  color: #64b5f6;
}

.feature-card h3 {
  font-size: 1.3rem;
  margin-bottom: 15px;
}

.feature-card p {
  font-size: 1rem;
  line-height: 1.5;
}

/* 技术栈 */
.tech-stack {
  text-align: center;
  margin-top: 30px;
}

.tech-stack h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.tech-items {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
}

.tech-item {
  background: rgba(0, 0, 255, 0.2);
  border-radius: 30px;
  padding: 8px 20px;
  font-size: 1rem;
  font-weight: 500;
  color: #f0f9ff;
  transition: all 0.3s ease;
}

.tech-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  background: rgba(0, 0, 255, 0.4);
}

/* 作者信息 */
.author-profile {
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 768px) {
  .author-profile {
    flex-direction: row;
    align-items: flex-start;
  }
}

.author-avatar {
  width: 200px;
  height: 200px;
  flex-shrink: 0;
  margin-bottom: 30px;
}

@media (min-width: 768px) {
  .author-avatar {
    margin-right: 40px;
    margin-bottom: 0;
  }
}

.avatar-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #64b5f6 0%, #1976d2 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: float 6s ease-in-out infinite;
}

.avatar-inner i {
  font-size: 100px;
  color: #f0f9ff;
}

.author-info {
  flex: 1;
}

.author-info h2 {
  font-size: 2rem;
  margin-bottom: 20px;
}

.author-bio {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 30px;
}

/* 技能条 */
.skills-container {
  margin-bottom: 30px;
}

.skills-container h3 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.skills-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.skill-item {
  width: 100%;
}

.skill-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.skill-name {
  font-weight: 500;
}

.skill-bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  overflow: hidden;
}

.skill-progress {
  height: 100%;
  background: linear-gradient(90deg, #64b5f6 0%, #1976d2 100%);
  border-radius: 5px;
  transition: width 1.5s ease-in-out;
}

/* 社交链接 */
.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  padding: 10px 20px;
  text-decoration: none;
  color: #f0f9ff;
  transition: all 0.3s ease;
  cursor: pointer;
}

.social-link:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-3px);
}

.social-link i {
  font-size: 1.2rem;
}

/* 底部区域 */
.footer-section {
  text-align: center;
  padding: 20px 0;
  margin-top: 30px;
  position: relative;
  z-index: 1;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .typing-text {
    font-size: 1.8rem;
  }

  .section-title {
    font-size: 1.8rem;
  }

  .section-description {
    font-size: 1rem;
  }

  .feature-card {
    padding: 20px;
  }

  .feature-card i {
    font-size: 2rem;
  }

  .feature-card h3 {
    font-size: 1.2rem;
  }

  .author-info h2 {
    font-size: 1.8rem;
  }

  .author-bio {
    font-size: 1rem;
  }
}

.contact-btn-container {
  margin-top: 24px;
  text-align: left;
}

.contact-btn {
  margin: 0;
  padding: 6px 18px;
  font-size: 1rem;
  font-weight: 500;
  color: #fff;
  background: rgba(100, 181, 246, 0.25);
  border: none;
  border-radius: 8px;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  text-decoration: none;
}

.contact-btn:hover {
  background: rgba(100, 181, 246, 0.45);
  color: #e3f2fd;
}

.author-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.contact-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 20, 40, 0.6);
  backdrop-filter: blur(6px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.contact-modal {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  padding: 30px;
  width: 90%;
  max-width: 400px;
  color: #f0f9ff;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 150, 255, 0.3);
  animation: scaleIn 0.3s ease;
}

.contact-modal h2 {
  font-size: 1.8rem;
  margin-bottom: 15px;
  color: #ffffff;
}

.contact-modal p {
  font-size: 1rem;
  margin-bottom: 25px;
  color: #e3f2fd;
}

.close-btn {
  background: linear-gradient(90deg, #1976d2 0%, #64b5f6 100%);
  border: none;
  padding: 10px 30px;
  color: white;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.close-btn:hover {
  background: linear-gradient(90deg, #64b5f6 0%, #1976d2 100%);
  transform: translateY(-2px) scale(1.05);
}

@keyframes fadeIn {
  from { opacity: 0 }
  to { opacity: 1 }
}

@keyframes scaleIn {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}


</style>
